package cn.ycc1.mylangchain4j.config;

import dev.langchain4j.model.chat.StreamingChatModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ycc
 * @date 2025/5/6
 */
@Configuration
public class AiConfig {
    @Value("${langchain4j.open-ai.chat-model.api-key}") // 从配置读取API密钥
    private String deepseekApiKey;

    @Bean
    public StreamingChatModel streamingChatModel() {
        return OpenAiStreamingChatModel.builder()
                .baseUrl("https://api.deepseek.com/v1")
                .apiKey(deepseekApiKey)
                .modelName("deepseek-chat")
                .build();
    }
}
